﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    /// <summary>
    /// Summary description for DAStation
    /// </summary>
    public class DACallLog : DbObject
    {
        protected SqlConnection connec;
        public DACallLog(SqlConnection Connection)
        {
            connec = Connection;
            //
            // TODO: Add constructor logic here
            //
        }

        public int Update(string ip_str_station_code, int ip_i_id)
        {
            int v_i_result = 0;
            SqlParameter[] parameters =  {	
                                             new SqlParameter("@StationCode", SqlDbType.VarChar,10) ,
                                             new SqlParameter("@Id", SqlDbType.Int,4)
										 };
            // set the 0values
            parameters[0].Value = ip_str_station_code;
            parameters[1].Value = ip_i_id;
            // create the parameter
            RunProcedure("sp_TB_Station_Update", parameters, out v_i_result, connec);
            return v_i_result;
        }
        public int Insert(string ip_str_DienThoai, string ip_str_AgenCode
                           , string ip_str_NoiDungLog, string ip_str_Callid, string ip_str_error_desc)
        {
            int v_i_result = 0;
            SqlParameter[] parameters =  {	
                                             new SqlParameter("@DienThoai", SqlDbType.VarChar,20)
                                            , new SqlParameter("@AgenCode", SqlDbType.VarChar,50)
                                            , new SqlParameter("@NoiDungLog", SqlDbType.NVarChar,450)
                                            , new SqlParameter("@CallId", SqlDbType.VarChar,20)
                                            , new SqlParameter("@error_desc", SqlDbType.VarChar,30)
										 };
            // set the 0values
            parameters[0].Value = ip_str_DienThoai;
            parameters[1].Value = ip_str_AgenCode;
            parameters[2].Value = ip_str_NoiDungLog;
            parameters[3].Value = ip_str_Callid;
            parameters[4].Value = ip_str_error_desc;
            RunProcedure("sp_TB_Call_Log_Insert", parameters, out v_i_result, connec);
            return v_i_result;
        }
        public int Delete(int ip_i_id)
        {
            int v_i_result = 0;
            SqlParameter[] parameters =  {	
                                             new SqlParameter("@Id", SqlDbType.Int,4)
										 };
            // set the 0values
            parameters[0].Value = ip_i_id;
            RunProcedure("sp_TB_Station_Delete", parameters, out v_i_result, connec);
            return v_i_result;
        }
    }
}